Report post

What are arrays in Ada?

Arrays provide another fundamental family of composite types in Ada. Arrays in Ada are used to define contiguous collections of elements that can be selected by indexing. Here's a simple example: The first point to note is that we specify the index type for the array, rather than its size.

What is an unconstrained array in Ada?

While unconstrained arrays in Ada might seem similar to variable length arrays in C, they are in reality much more powerful, because they're truly first-class values in the language. You can pass them as parameters to subprograms or return them from functions, and they implicitly contain their bounds as part of their value.

Can Ada declare array types whose bounds are not fixed?

However, Ada also allows you to declare array types whose bounds are not fixed: in that case, the bounds will need to be provided when creating instances of the type. The fact that the bounds of the array are not known is indicated by the Days range syntax.

What does > mean in Ada?

You can use to mean "default initialization", and since Ada float types don't have default initializers, it means initialize to garbage. (others => (Quantity => 0, Price => )). I don't understand why you would need this, though. It seems best to initialize it to some value.

Related articles

The World's Leading Crypto Trading Platform

Get my welcome gifts